import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import interp1d

str='''28.8472565	0.5
56.7618276	0.51
83.79536544	0.52
109.9953775	0.53
135.4124683	0.54
160.0697233	0.55
184.0041443	0.56
207.240218	0.57
229.8137192	0.58
251.7448582	0.59
273.072909	0.6
293.8164549	0.61
314.0197567	0.62
333.6939905	0.63
352.8672763	0.64
371.5610345	0.65
389.7854197	0.66
407.5642829	0.67
424.9037001	0.68
441.8210154	0.69
458.339493	0.7
474.4702785	0.71
490.2320745	0.72
505.6456904	0.73
520.7176304	0.74
535.4615761	0.75
549.8857737	0.76
564.0017227	0.77
577.8149894	0.78
591.3350363	0.79
604.5707277	0.8
617.5348684	0.81
630.2427155	0.82
642.7015035	0.83
654.919551	0.84
666.9041062	0.85
678.6585789	0.86
690.1900514	0.87
701.5017741	0.88
712.6021757	0.89
723.4932331	0.9
734.1833129	0.91
744.6842376	0.92
755.0049817	0.93
765.1476255	0.94
775.1161258	0.95
784.913272	0.96
794.5451895	0.97
804.0116257	0.98
813.3161115	0.99
822.4626906	1
'''

str_2='''28.92558439
55.73702729
82.28081379
107.999918
132.9346464
157.1227094
180.5991786
203.3970596
225.5470982
247.0784015
268.018015
288.3916015
308.2232306
327.5355921
346.3501829
364.6871164
382.5654848
400.0033384
417.0178346
433.6251354
449.8405514
465.6786692
481.1533219
496.2776354
511.0641396
525.5247357
539.6706706
553.5127644
567.0613089
580.3260993
593.316519
606.0415059
618.5095775
630.728907
642.7073401
654.4523116
665.9710156
677.2703196
688.3567824
699.2367607
709.9162843
720.4011609
730.6969861
740.8091119
750.7427391
760.5028049
770.0940744
779.5211473
788.7884292
797.9002118
806.8605719
'''



str_split=str.split()
size=len(str_split)
x_value=[float(str_split[i]) for i in range(size) if i%2==0]
y_value=[float(str_split[i]) for i in range(size) if i%2==1]
# 给定的两组数组
x = np.array(x_value)
y = np.array(y_value)

str_split_2=str_2.split()
size=len(str_split_2)
x_new_value=[float(str_split_2[i]) for i in range(size)]

# 创建插值函数
# kind可以是'linear', 'nearest', 'zero', 'slinear', 'quadratic', 'cubic'等
f = interp1d(x, y, kind='cubic')

# 使用插值函数计算新的y值
y_new = f(np.array(x_new_value))
for y in y_new.tolist():
    print(y)
